part of 'dialog_util.dart';

class AlertDialog extends CupertinoAlertDialog {
  AlertDialog({
    Key? key,
    this.titleText,
    this.msg,
    this.cancelText,
    this.sureText,
    this.cancelColor,
    this.sureColor,
    this.cancelAction,
    this.sureAction,
  }) : super(
          key: key,
          title: titleText == null
              ? null
              : Text(
                  titleText,
                  style: TextStyle(
                      color: const Color(0xff333333), fontSize: 18.sp),
                ),
          content: msg == null
              ? null
              : Text(
                  msg,
                  style: TextStyle(
                      color: const Color(0xff666666), fontSize: 15.sp),
                ),
          actions: [
            Visibility(
              visible: cancelText != null,
              child: CupertinoDialogAction(
                onPressed: () {
                  Navigator.of(Get.context!).pop();
                  if (cancelAction != null) {
                    Future.delayed(const Duration(milliseconds: 300), () {
                      cancelAction();
                    });
                  }
                },
                child: Text(
                  cancelText ?? '',
                  style: TextStyle(
                      color: cancelColor ?? const Color(0xff999999),
                      fontSize: 13.sp),
                ),
              ),
            ),
            Visibility(
              visible: sureText != null,
              child: CupertinoDialogAction(
                onPressed: () {
                  Navigator.of(Get.context!).pop();
                  if (sureAction != null) {
                    Future.delayed(const Duration(milliseconds: 300), () {
                      sureAction();
                    });
                  }
                },
                child: Text(
                  sureText ?? '',
                  style: TextStyle(
                      color: cancelColor ?? const Color(0xff43a8e8),
                      fontSize: 13.sp),
                ),
              ),
            ),
          ],
        );
  final String? titleText;
  final String? msg;
  final String? cancelText;
  final String? sureText;
  final Color? cancelColor;
  final Color? sureColor;
  final VoidCallback? cancelAction;
  final VoidCallback? sureAction;
}
